		<!--{eval $image_uploadify_id=$content_textarea_id.$image_uploadify_type.($image_uploadify_topic[tid]>0?"_".$image_uploadify_topic[tid]:"");}-->
		<!--{eval $image_uploadify_image_small_size=$image_uploadify_image_small_size?$image_uploadify_image_small_size:45;}-->
		<!--{eval $content_textarea_id=$content_textarea_id?$content_textarea_id:'i_already'.{$h_key};}-->
		<!--{eval $content_textarea_empty_val=isset($content_textarea_empty_val)?$content_textarea_empty_val:'#分享图片#';}-->
		<!--{eval $image_uploadify_queue_size_limit=max(0, (int) $this->Config[image_uploadify_queue_size_limit]);if($image_uploadify_queue_size_limit<1)$image_uploadify_queue_size_limit=3;}-->
		<!--{eval $img_item=isset($this->item)?$this->item:'';}-->
		<!--{eval $img_itemid=isset($this->item_id)?$this->item_id:0;}-->
		<success></success>
		
		<!-- <script type="text/javascript" src="images/uploadify/jquery.uploadify.v2.1.4.min.js"></script> -->
		<script type="text/javascript">
		
		var __IMAGE_IDS__ = {};
		
		$(document).ready(function(){
			
			$('#publisher_file{$image_uploadify_id}').uploadify({
				'uploader'  : '{conf site_url}/images/uploadify/uploadify.swf?id={$image_uploadify_id}&random=' + Math.random(),
			    'script'    : '{echo urlencode({conf site_url} . "/ajax.php?mod=uploadify&code=image&uninitmember=1&type=flash&iitem={$img_item}&iitemid={$img_itemid}")}',
			    'cancelImg' : '{conf site_url}/images/uploadify/cancel.png',
			    'buttonImg'	: '{conf site_url}/images/uploadify/tj.jpg',
			    'width'		: 160,
			    'height'	: 48,
			    'multi'		: true,
			    'auto'      : true,
			    'sizeLimit' : '{conf image_size_limit}',
			    'fileExt'	: '*.jpg;*.png;*.gif;*.jpeg',
			    'fileDesc'	: '请选择图片文件(*.jpg;*.png;*.gif;*.jpeg)',
			    'queueID'	: 'uploadifyQueueDiv{$image_uploadify_id}',
			    'wmode'		: 'transparent',
			    'fileDataName'	 : 'topic',
			    'queueSizeLimit' : {$image_uploadify_queue_size_limit},
			    'simUploadLimit' : 1,
			    'scriptData'	 : {
			    	{if $image_uploadify_topic_uid}
			    	'topic_uid'  : '{$image_uploadify_topic_uid}',
			    	{/if}
			    	'cookie_auth': '{echo urlencode(jsg_getcookie("auth"))}'
			    },
			    'onSelect'		 : function(event, ID, fileObj) {
			    },
			    'onSelectOnce'	 : function (event, data) {
			    	imageUploadifySelectOnce{$image_uploadify_id}();			    	
			    },
			    'onProgress'     : function(event, ID, fileObj, data) {
			        return false;
			    },
			    'onComplete'	 : function(event, ID, fileObj, response, data) {
			    	eval('var r = ' + response + ';');
					if (r.done) {					
						var rv = r.retval;
						if ( rv.id > 0 && rv.src.length > 0 ) {
							imageUploadifyComplete{$image_uploadify_id}(rv.id, rv.src, fileObj.name);
						}
					}
			    },
			    'onError'        : function (event, ID, fileObj, errorObj) {
			        alert(errorObj.type + ' Error: ' + errorObj.info);
			    },
			    'onAllComplete'	 : function(event, data) {
			    	imageUploadifyAllComplete{$image_uploadify_id}();
			    }
			});
			
			
			$("#viewImgDiv{$image_uploadify_id} img").each(function() {
			    if($(this).width() > $(this).parent().width()) {
			    	$(this).width("100%");
				}
			});
			
				
		});
		
		
		//删除一张图片
		function imageUploadifyDelete{$image_uploadify_id}(idval)
		{
			var idval = ('undefined'==typeof(idval) ? 0 : idval);
			if(idval > 0) 
			{
				$.post
				(
					'ajax.php?mod=uploadify&code=delete_image',
					{
						'id' : idval
					},
					function (r) 
					{				
						if(r.done)
						{
							$('#uploadImgSpan_' + idval).remove();
							
                            var contentTextBox = $('#'+__CONTENTID__);
                            var content = contentTextBox.val();
                            var r = "[image]"+idval+"[/image]";
                            var n = content.split(r).length - 1;
                            for (var i = 0; i < n ; i++) {
                                content = content.replace(r,"");
                            }
                            contentTextBox.val(content);
                            
							if( ($.trim(($('#viewImgDiv{$image_uploadify_id}').html()))).length < 1 )
							{
								$('#viewImgDiv{$image_uploadify_id}').css('display', 'none');
								$('#insertImgDiv{$image_uploadify_id}').css('display', 'block');
							}
							
							if( 'undefined' != typeof(__IMAGE_IDS__[idval]) )
							{
								__IMAGE_IDS__[idval] = 0;
							}
						}
						else
						{
							if(r.msg)
							{
								MessageBox('warning', r.msg);
							}
						}
					},
					'json'
				);
			}
		}
        
		function imageUploadifySelectOnce{$image_uploadify_id}()
		{
			$('#uploading{$image_uploadify_id}').html("<img src='images/loading.gif'/>&nbsp;上传中，请稍候……");
		}
		
		function imageUploadifyComplete{$image_uploadify_id}(idval, srcval, nameval)
		{
			var imageIdsCount = 0;
	    	$.each( __IMAGE_IDS__, function( k, v ) { if( v > 0 ) { imageIdsCount += 1; } } );
	    	if( imageIdsCount >= {$image_uploadify_queue_size_limit} )
	    	{
	    		MessageBox('warning', '本次图片数量超过限制了');
	    		return false;
	    	}
			
			var idval = ('undefined' == typeof(idval) ? 0 : idval);
			var srcval = ('undefined' == typeof(srcval) ? 0 : srcval);
			var nameval = ('undefined' == typeof(nameval) ? '' : nameval);
			var contentId = '{$content_textarea_id}';
			{if 'topic_publish'==$image_uploadify_from}
				$('#viewImgDiv{$image_uploadify_id}').prepend('<li id="uploadImgSpan_' + idval + '" class="menu_cs vv_2"><a href="javascript:;" id="insert_image_'+idval+'" onclick="insertIntoContent(\'image\','+idval+',\''+contentId+'\');" title="点击插入"><img sr' + 'c' + '=' + '"' + srcval + '"/></a> <p><i>' + nameval + ' <a title="删除图片" onclick="imageUploadifyDelete{$image_uploadify_id}(' + idval + ');return false;" href="javascript:;">删除</a></i></p></li>');
			{elseif 'topic_longtext_info_ajax'==$image_uploadify_from}			
				$('#viewImgDiv{$image_uploadify_id}').append('<span id="uploadImgSpan_' + idval + '"><img s' + 'rc' + '="' + srcval + '" width="{$image_uploadify_image_small_size}" alt="点击图片插入到文中" onclick="longtext_info_img_insert(\'' + srcval + '\');" /><a href="javascript:void(0);" onclick="imageUploadifyDelete{$image_uploadify_id}(' + idval + '); return false;" title="删除图片">×</a></span>');
			{else}
				$('#viewImgDiv{$image_uploadify_id}').append('<span id="uploadImgSpan_' + idval + '"><a href="javascript:;" id="insert_image_'+idval+'" onclick="insertIntoContent(\'image\','+idval+',\''+contentId+'\');" title="点击插入"><img sr' + 'c' + '="' + srcval + '" width="{$image_uploadify_image_small_size}" /></a><a href="javascript:void(0);" onclick="imageUploadifyDelete{$image_uploadify_id}(' + idval + '); return false;" title="删除图片">×</a></span>');
			{/if}
			
			$('#normalUploadFile{$image_uploadify_id}').val('');
			
			__IMAGE_IDS__[idval] = idval;
		}
		
		function imageUploadifyAllComplete{$image_uploadify_id}()
		{
			$('#uploading{$image_uploadify_id}').html('');			    	
	    	$('#viewImgDiv{$image_uploadify_id}').css('display', 'block');
	    	//$('#insertImgDiv{$image_uploadify_id}').css('display', 'none');
	    	if( $.trim(($('#{$content_textarea_id}').val())).length < 1 ) {
	    		$('#{$content_textarea_id}').val('{$content_textarea_empty_val}');	
	    	}
	    	$('#{$content_textarea_id}').focus();
		}
		
		function normalUploadFormSubmit{$image_uploadify_id}()
		{
			var fileVal = $('#normalUploadFile{$image_uploadify_id}').val();
			
			if(($.trim(fileVal)).length < 1)
			{
				MessageBox('warning', '请选择一个正确的图片文件');
				return false;
			}
			else
			{
				if(!(/\.(jpg|png|gif|jpeg)$/i.test(fileVal)))
				{
					MessageBox('warning', '请选择一个正确的图片文件');
					return false;
				}
				else
				{
					imageUploadifySelectOnce{$image_uploadify_id}();
					
					return true;
				}
			}
		}
        
        /**
        * 上传网络图片
        */
        function getUrlImage(url){
            var url = $.trim(url.value);
            if(!url){
                show_message("请输入你要上传的网络图片地址");
                return false;
            }
            if (!/.(gif|jpg|png|jpeg)$/i.test(url)) {
                show_message("请上传jpg、jpeg、gif、png格式的图片。");
                return false;
            }
            
            $("#uploading_img").show();

            $.post(
                'ajax.php?mod=uploadify&code=urlimage',
                {url:url,
                type:'flash'},
                function (r) {
                    $("#uploading_img").hide();
                    if (r.done) {
                        var rv = r.retval;
                        if ( rv.id > 0 && rv.src.length > 0 ) {
                            
                            var imageIdsCount = 0;
                            $.each( __IMAGE_IDS__, function( k, v ) { if( v > 0 ) { imageIdsCount += 1; } } );
                            if( imageIdsCount >= {$image_uploadify_queue_size_limit} )
                            {
                                MessageBox('warning', '本次图片数量超过限制了');
                                return false;
                            }

                            var idval = rv.id;
                            var srcval = rv.src;
                            var nameval = '';

                            $('#viewUrlImgDiv').html('<li id="uploadImgSpan_' + idval + '" class="menu_cs vv_2"><a href="javascript:;" id="insert_image_'+idval+'" onclick="insertIntoContent(\'image\','+idval+');" title="点击插入"><img sr' + 'c' + '=' + '"' + srcval + '"/></a> <p><i>' + nameval + ' <a title="删除图片" onclick="imageUploadifyDelete{$image_uploadify_id}(' + idval + ');return false;" href="javascript:;">删除</a></i></p></li>');

                            $('#img_url').val('');
                            
                            __IMAGE_IDS__[idval] = idval;
                        }
                    } else {
                        show_message(r.msg);
                    }
                    return false;
                },'json'
            );
        }
		
		function imageUploadifyModuleSwitch{$image_uploadify_id}()
		{
			if('none' == $('#normalUploadDiv{$image_uploadify_id}').css('display'))
			{
				$('#uploadDescModuleSpan{$image_uploadify_id}').html('快速');
				
				$('#swfUploadDiv{$image_uploadify_id}').css('display', 'none');
				$('#normalUploadDiv{$image_uploadify_id}').css('display', 'block');
			}
			else
			{
				$('#uploadDescModuleSpan{$image_uploadify_id}').html('普通');
				
				$('#normalUploadDiv{$image_uploadify_id}').css('display', 'none');
				$('#swfUploadDiv{$image_uploadify_id}').css('display', 'block');
			}
		}
		
		</script>
		<!--{if !$image_uploadify_only_js}-->
        <div id="insertImgDiv{$image_uploadify_id}" class="insertImgDiv">
        <span class="arrow-up"></span>   
        <span class="arrow-up-in"></span>
        <i class="insertImgDiv_up_{$image_uploadify_id} insertImgDiv_up" onclick="$(this).parent().hide()"><img src="images/imgdel.gif" title="关闭" /></i>
		    <div id="swfUploadDiv{$image_uploadify_id}"><input type="file" id="publisher_file{$image_uploadify_id}" name="publisher_file{$image_uploadify_id}" style="display:none;" /></div>
		    <iframe id="imageUploadifyIframe{$image_uploadify_id}" name="imageUploadifyIframe{$image_uploadify_id}" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank" style="display:none;"></iframe>
		    <div id="normalUploadDiv{$image_uploadify_id}" style="display:none;">
				<form id="normalUploadForm{$image_uploadify_id}" method="post" action="ajax.php?mod=uploadify&code=image&type=normal&iitem={$img_item}&iitemid={$img_itemid}" enctype="multipart/form-data" target="imageUploadifyIframe{$image_uploadify_id}" onsubmit="return normalUploadFormSubmit{$image_uploadify_id}()">
		    		<input type="hidden" name="image_uploadify_id" value="{$image_uploadify_id}" />
		    		<input type="file" id="normalUploadFile{$image_uploadify_id}" name="topic" />
		    		<input type="submit" value="上传" class="tul" />
		    	</form>
		    </div>
			<span id="uploading{$image_uploadify_id}"></span>
			<div id="uploadDescDiv{$image_uploadify_id}">
				<span class="fontRed">*</span> 如不能上传图片，可以<a href="javascript:;" onclick="imageUploadifyModuleSwitch{$image_uploadify_id}();">点击这里</a>用<span id="uploadDescModuleSpan{$image_uploadify_id}">普通</span>模式上传；<br />
				<span class="fontRed">*</span> 最多可上传{conf image_uploadify_queue_size_limit}张图片，单张图片大小不超过{eval echo(round($this->Config[image_size]/1024, 2));}M。				
				{if 'topic_longtext_info_ajax'==$image_uploadify_from}
				<br /><span class="fontRed">*</span> 图片上传成功后，可以点击图片将图片插入到您想要的位置
				{/if}
				<!-- 
				<br />*可上传JPG、JPEG、GIF、PNG图片格式（小于2M）
				<br />*可直接将网上图片URL地址复制到发布框来发布
				-->
			</div>
            
            
            
            		<div id="uploadifyQueueDiv{$image_uploadify_id}" style="display:none;"></div>
        <div id="viewImgDiv{$image_uploadify_id}" class="viewImgDiv">
        	<!--{if (!$image_uploadify_new || $image_uploadify_modify) && $image_uploadify_topic[imageid]}-->        	
        	<!--{loop $image_uploadify_topic[image_list] $ik $iv}-->
        	<script type="text/javascript"> __IMAGE_IDS__[{$ik}] = $ik; </script>
        	<span id="uploadImgSpan_{$ik}">
	        	<img src="{$iv[image_small]}" width="{$image_uploadify_image_small_size}" />
	        	<a href="javascript:void(0);" onclick="imageUploadifyDelete{$image_uploadify_id}('$ik'); return false;" title="删除图片">×</a>
        	</span>
        	<!--{/loop}-->
        	<!--{/if}-->
        </div>
            
            
            
	    </div>

        <!--{/if}-->